# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=myst-parser
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.0.1
pkgrel=1
pkgdesc="An extended commonmark compliant parser, with bridges to docutils/sphinx (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'purl: pkg:pypi/myst-parser'
)
msys2_repository_url='https://github.com/executablebooks/MyST-Parser/'
url='https://myst-parser.readthedocs.io/'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-docutils"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-markdown-it-py"
         "${MINGW_PACKAGE_PREFIX}-python-mdit_py_plugins"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions"
         "${MINGW_PACKAGE_PREFIX}-python-sphinx"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-flit-core")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('5cfea715e4f3574138aecbf7d54132296bfd72bb614d31168f48c477a830a7c4')

build() {
  cp -r "${_realname/-/_}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
